extends AnimatedSprite

onready var Game = get_tree().current_scene.get_node(".")
var health = 300
var has_shoot = false

func _ready():
	pass

func has_zombie():
	return $RayCast2D.get_collider() 
	pass

func _process(delta):
	if has_zombie() and has_shoot == false:
		shoot()
		has_shoot = true
	if health <= 0:
		queue_free()
	pass
	
func shoot():
	var bullet = load("res://object/WandouBullet.tscn").instance()
	add_child(bullet)
	#print_debug(bullet)
	pass


func _on_Area2D_input_event(viewport, event, shape_idx):
	if event is InputEventMouseButton:
		if event.is_pressed() and event.button_index == BUTTON_LEFT:
			if Game.use_shovel:
				Game.reset_shovel()
				Game.use_shovel = false
				self.queue_free()
			elif Game.use_nld:
				on_nld()
	pass # Replace with function body.
# 能力豆
func on_nld():
	for i in 40:
		shoot()
	pass
